<template>
  <el-dialog
    :title="title"
    :visible.sync="visible"
    width="30%" @open="openDialog">
    <el-row style="line-height: 40px; ">
      <el-col :span="8">
        <span v-text='label'/>
      </el-col>
      <el-col :span="16">
        <el-input v-model="result"></el-input>
      </el-col>
    </el-row>
    <span class="dialog-footer" slot="footer">
      <el-button @click="visible = false">取 消</el-button>
      <el-button type="primary" @click="confirm">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
  export default {
    name: "InputDialog",
    data() {
      return {
        visible: false,
        result: '',
      }
    },
    props: {
      nullable: {
        type: Boolean,
        default: false,
      },
      title: {
        type: String,
        default: 'wahaha',
      },
      label: {
        type: String,
        default: '请输入'
      },
      value: {
        type: String
      }
    },
    methods: {
      confirm(){
        if (!this.nullable && UTIL.isEmpty(this.result)) {
          this.$message.warning('输入内容不能为空')
          return
        }
        this.$emit('callback', this.result)
        this.visible = false
      },
      openDialog() {
        this.result = this.value
      }
    }
  }
</script>

<style scoped>

</style>
